#include "TcpServer.hpp"
#include "ComExcute.hpp"

void Usage(std::string proc)
{
    std::cout << "Usage:\n\t" << proc << "local_port\n"
              << std::endl;
}
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERROR);
    }
    ComExcute cmd("safe.txt");
    uint16_t port = std::atoi(argv[1]);
    std::unique_ptr<TcpServer> tcp = std::make_unique<TcpServer>(port,
        std::bind(&ComExcute::Excute, &cmd, std::placeholders::_1));

    tcp->InitServer();
    tcp->Loop();

    return 0;
}
